from typing import Union

from fastapi import FastAPI
import src.wlff_mysql
app = FastAPI()



@app.get("/",summary='select调试接口')
def read_root():
    return {"result": src.wlff_mysql.selectUser()}


@app.get("/user/create",summary='用户创建接口')
def userCreate(password: Union[str, None] = None, name: Union[str, None] = None):

    return {"result": src.wlff_mysql.createUser(name, password)}
@app.get("/book/borrow",summary='借书接口')
def borrow(bookId: Union[int, None] = None, num: Union[int, None] = None,password: Union[str, None] = None, name: Union[str, None] = None):
    return {"result": src.wlff_mysql.borrow(bookId, num, name, password)}
@app.get("/book/returnbooks",summary='还书接口')
def returnbooks(bookId: Union[int, None] = None, num: Union[int, None] = None,password: Union[str, None] = None, name: Union[str, None] = None):
    return {"result": src.wlff_mysql.returnBooks(bookId, num, name, password)}

